    
        
        
        
        
        
    
function changeSate(id, state) {
    $.ajax({
        type: 'POST',
        url: "changeState",
        data: {
            id: id,
            state: state
        },
        success: function () {
            $('#mytable').bootstrapTable('refresh', {url: '/admin/userext/list'});
        },
        dataType: "json"
    });
}

function deleteOne(id) {
    layer.confirm('您确定要删除此行数据？', {
        btn: ['确定','取消'] //按钮
    }, function(){
        $.ajax({
            type: 'POST',
            url: "deleteOne",
            data: {
                id: id,
            },
            success: function (status) {
                if (status == 1) {
                    layer.msg('删除成功', {icon: 1});
                    $('#mytable').bootstrapTable('refresh', {url: '/admin/userext/list'});
                }else {
                    layer.msg('删除失败', {icon: 1});
                }
            },
            dataType: "json"
        });

    }, function(){
        layer.msg('您已取消操作', {
            time: 1000, //20s后自动关闭
            btn: ['明白了', '知道了']
        });
    });
}

var editsw=[];
/**
 * 为模态框填充数据
 */
$('#modal-form').on('show.bs.modal', function (event) {
    var button = $(event.relatedTarget); // 触发事件的按钮
    var id = button.data('row');
    console.log(button.data('row'))
    var modal = $(this);
    $.ajax({
        type: 'POST',
        url: "getUserExtById",
        data: {
            id: id
        },
        success: function (data) {
            console.log(data)

                                                                                            modal.find('#tags').val(data.tags)
                                                                modal.find('#workyears').val(data.workyears)
                                                                modal.find('#restday').val(data.restday)
                                                                modal.find('#sid').val(data.sid)
                                                                modal.find('#mpid').val(data.mpid)
                            
            if(data.state==1){
                modal.find('#state').attr("checked",'checked').val("1");
            }
        },
        dataType: "json"
    });
})

//tableHeight函数
function tableHeight(){
    //可以根据自己页面情况进行调整
    return $(window).height() -200;
}
$(function() {
    var sw = [];
    $(".js-switch").each(function (i,e) {
        sw[i] = new Switchery(e, {color: "#1AB394"})
    })

    $(window).resize(function () {
        $('#mytable').bootstrapTable('resetView', {
            height: tableHeight()
        })
    })

    //生成用户数据
    $('#mytable').bootstrapTable({
        method: 'get',
        url:"/admin/userext/list",
        // height:520,//高度调整
        // toolbar: '#toolbar',
        striped: true, //是否显示行间隔色
        dataField: "records",
        pagination:true,//是否分页
        queryParamsType:'limit',
        queryParams:queryParams,
        sidePagination:'server',
        pageNumber: 1, //初始化加载第一页，默认第一页
        pageSize:50,//单页记录数
        pageList:[50,100,200,500],//分页步进值
        showExport:true,//显示导出
        showRefresh:false,//刷新按钮
        showColumns:false,
        clikToSelect: true,//是否启用点击选中行
        // toolbarAlign:'right',
        // buttonsAlign:'right',//按钮对齐方式
        columns:[
             {
                 title:'全选',
                 field:'select',
                 checkbox:true,
                 width:25,
                 align:'center',
                 valign:'middle'
            },
            {
                title:'ID',
                field:'id',
                visible:false
            },
                                                                                                    {
                            title:'用户标签',
                            field:'tags'
                        },
                                                                                                            {
                            title:'工作年限',
                            field:'workyears'
                        },
                                                                                                            {
                            title:'固定休息日子#w1：周一；m3：每月3号；多个用英文分号区分',
                            field:'restday'
                        },
                                                                                                                    {
                title:'操作',
                field:'Attribute',
                align:'center',
                formatter:actionFormatter
            }
        ],
        locale:'zh-CN',//中文支持,
    })

    //请求服务数据时所传参数
    function queryParams(params){
        console.log(params)
        return params;
    }

})